<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<!--在这里写你的css-->
<div th:fragment="stylesheet">

</div>
<!--在这里写你的内容-->

<body id="test" th:fragment="content">

<div class="panel" style="padding: 10px">
    <div class="panel-heading">
        <h3 class="panel-title">添加药品</h3>
    </div>
    <form name="add_news">
        <div>
            <div class="box-body col-md-6">
                <label for="id">药品编号</label>
                <input id="id" type="text" class="form-control" placeholder="输入药品编号">
                <br>
                <label for="name">药品名称</label>
                <input id="name" type="text" class="form-control" placeholder="输入药品名称">
                <br>
                <label for="alias">别名</label>
                <input id="alias" type="text" class="form-control" placeholder="输入药品别名">
                <br>
                <label for="foreignName">英文名称</label>
                <input id="foreignName" type="text" class="form-control" placeholder="输入英文名称">
                <br>
                <label for="pharmacology">药理毒理</label>
                <input id="pharmacology" type="text" class="form-control" placeholder="输入药理毒理">
                <br>
                <label for="characteristics">作用特点</label>
                <input id="characteristics" type="text" class="form-control" placeholder="输入作用特点">
                <br>
                <label for="dmpk">药物动力学</label>
                <input id="dmpk" type="text" class="form-control" placeholder="输入药物动力学">
                <br>
                <label for="facility">功能</label>
                <input id="facility" type="text" class="form-control" placeholder="输入药物功能">
                <br>
            </div>

            <div class="box-body col-md-6">
                <label for="major">主治</label>
                <input id="major" type="text" class="form-control" placeholder="输入主治">
                <br>
                <label for="target">适应症</label>
                <input id="target" type="text" class="form-control" placeholder="输入适应症">
                <br>
                <label for="shape">性状</label>
                <input id="shape" type="text" class="form-control" placeholder="输入性状">
                <br>
                <label for="medicineUsage">用法用量</label>
                <input id="medicineUsage" type="text" class="form-control" placeholder="输入用法用量">
                <br>
                <label for="notice">注意事项</label>
                <input id="notice" type="text" class="form-control" placeholder="输入注意事项">
                <br>
                <label for="badReaction">不良反应</label>
                <input id="badReaction" type="text" class="form-control" placeholder="输入不良反应">
                <br>
                <label for="contraindication">禁忌症</label>
                <input id="contraindication" type="text" class="form-control" placeholder="输入禁忌症">
                <br>
                <label for="size">规格</label>
                <input id="size" type="text" class="form-control" placeholder="输入规格">
                <br>
            </div>

        </div>

        <div  class="box-body ">
            <button id="submit" type="button" class="btn btn-primary btn-block">确定</button>
        </div>

    </form>
</div>
</body>
<!--在这里定义或者引用你的script-->
<div th:fragment="script">
    <script>
    $('#submit').click(function() {
        if ($.trim($("#id").val()) == "") {
            alert("标题不能为空")
        } else {
            $.ajax({
                type: "post",
                url: "/contents/medicine/add",
                data: {
                    id: $("#id").val(),
                    name: $("#name").val(),
                    alias: $("#alias").val(),
                    foreignName: $("#foreignName").val(),
                    pharmacology: $("#pharmacology").val(),
                    characteristics: $("#characteristics").val(),
                    dmpk: $("#dmpk").val(),
                    facility: $("#facility").val(),
                    major: $("#major").val(),
                    medicineUsage: $("#medicineUsage").val(),
                    notice: $("#notice").val(),
                    badReaction: $("#badReaction").val(),
                    contraindication: $("#contraindication").val(),
                    size: $("#size").val()
                },
                success: function (data) {
                    alert("successful");
                    $("#test").load(location.href + "#test");//重新加载整个<body>
                },
                error: function (data) {
                    alert("error");
                }
            })
        }
    })
    </script>
</div>

</html>